package com.spring.dao.example.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.spring.bean.example.Sort;
import com.spring.bean.page.Page;
import com.spring.bean.page.PageView;
import com.spring.dao.DaoSupport;
import com.spring.dao.example.SortDao;
import com.spring.exception.DaoException;

@Repository
public class SortDaoImpl extends DaoSupport implements SortDao{

	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@Override
	public List<Sort> queryForList() throws DaoException {
		String sql = "select * from sort";
		return queryForList(jdbcTemplate, Sort.class, sql);
	}

	@Override
	public boolean add(Sort sort) throws DaoException {
		return insert(jdbcTemplate, sort);
	}

	@Override
	public boolean delete(Sort sort) throws DaoException {
		return delete(jdbcTemplate, sort);
	}
	
	@Override
	public Sort getById(Integer id) throws DaoException {
		return getById(jdbcTemplate, Sort.class, id);
	}
	
	public PageView<Sort> queryForPage(Page page) throws DaoException {
		String sql = "";
		return queryCacheForPage(jdbcTemplate, Sort.class, sql, page, true);
	}

}
